<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../config.inc.php");
$_LangPath = "left_account";	//語言檔參數，務必放在最前面

include_once(__Member_Path."/logincheck.php");
include_once(__Language_Path."/selectlanguage_member.php");
include_once(__Common_Path."/ExchangeRate.inc.php");
include_once(__Modules_Path."/Wager.lib.php");
include_once(__Modules_Path."/WagerForm.lib.php");

$objMemberInfo = $_SESSION["Member_Info"];

if(empty($objMemberInfo -> ReflashTime) || (time() - $objMemberInfo -> ReflashTime) > 120){
	$_SESSION["Member_Info"] -> ReflashTime = time();
//產生累積注額陣列
	if(!getWagerArrayGold($objMemberInfo -> ID)){
		$Err_Message = $GLOBALS["errormessage"];
		$Err_HiddenMessage = $GLOBALS["errorhidden"];
		include("wager_error.php");
	}
}
include_once(__Root_Path."/tmp/credit-".$objMemberInfo -> ID.".php");
if(empty($_arrMemStake["_SUM"]))$_arrMemStake["_SUM"] = 0;

$fp = @file(__Membertemplate_Path."/account.html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);
$fp = str_replace("{MemAccount}", $objMemberInfo -> Account, $fp);

if(__isConnectToOtherWeb == 1){
	$fp = str_replace("{MemCurrency}", $objMemberInfo -> ExName, $fp);
	$fp = str_replace("{ShowMemERate}", $objMemberInfo -> ExRate, $fp);
}else{
	$fp = str_replace("{MemCurrency}", $_ECRate[$objMemberInfo -> ERID][$_intLang], $fp);
	$fp = str_replace("{ShowMemERate}", $_ECRate[$objMemberInfo -> ERID]["Rate"], $fp);
}

$fp = str_replace("{CreditLine}", $objMemberInfo -> CreditLine, $fp);

if(__isUseOldCreditLine == 1){
	$fp = preg_replace("/<!-- @ NewCredit Start @ \/\/-->.+<!-- @ NewCredit End @ \/\/-->/s", "", $fp);
	$fp = str_replace("{Usedmoney}", $_strLeft_Account["UsedGold"], $fp);
	$fp = str_replace("{UsedCreditLine}", $_arrMemStake["_SUM"], $fp);
}

$fp = str_replace("{WinLose}", $_arrMemStake["_Result"], $fp);
$fp = str_replace("{UsedCreditLine}", $_arrMemStake["_Wager"], $fp);
$fp = str_replace("{BalanceCreditLine}", ($objMemberInfo -> CreditLine - $_arrMemStake["_SUM"]), $fp);
$fp = str_replace("{LottoID}", $_data[LottoID], $fp);

while(list($k, $v) = each($_strLeft_Account)){
	$fp = str_replace("{".$k."}", $v, $fp);
}


$strSQL = "select a.ID, a.LottoID, b.BetDate, a.Number as Number, b.BetTime, a.Bet_Type, b.Content, a.MemStake, a.MemPayOff, a.LottoID, a.isPayOff, b.OneStake from `bet_BetListTmp` a, `bet_BetListContent` b where a.isPayOff = 0 and a.MemID = ".$objMemberInfo -> ID." and a.ID = b.ID order by a.ID desc limit 0, 10";
if(!$RS = @PMA_mysql_query($strSQL, $$_Conn)){
	$GLOBALS["errormessage"] = "Error";
	$GLOBALS["errorhidden"] = "Error: ".PMA_mysql_error($$_Conn)."\nLine:".__LINE__."\nPage:".__FILE__;
	ErrMsgOutputHTML("Error", "", 1);
}
$arrRows = array();
if(mysql_num_rows($RS) > 0){
	while($Rows = mysql_fetch_object($RS)){
		$strTmpCon = WagerFormTrans($Rows -> LottoID, $Rows -> Bet_Type, $Rows -> Content);
		$arrRows[] = $strTmpCon."--\$".$Rows -> MemStake;
	}
}
if(sizeof($arrRows) == 0){
	$fp = preg_replace("/<!-- @ LastWager Start @ \/\/-->.+<!-- @ LastWager End @ \/\/-->/s", "", $fp);
}else{
	$fp = str_replace("{LastWager}", implode("\n<br />", $arrRows), $fp);
}
$fp = str_replace("<!--AD Image//-->", $strAD, $fp);
//輸出
WebOutputHTML($fp, 1);
?>